\documentclass[a4paper]{article}

\usepackage{lscape}
\usepackage{pstricks}
\usepackage{pst-grad}
\usepackage{pst-xkey}
\usepackage{multido}

\makeatletter

% "pspicture" environment or not?
\newif\ifPst@PstPicture
\define@key[psset]{}{PstPicture}[true]{\@nameuse{Pst@PstPicture#1}}
% Intervals to show?
\newif\ifPst@GanttChartShowIntervals
\define@key[psset]{}{ChartShowIntervals}[true]{\@nameuse{Pst@GanttChartShowIntervals#1}}
% Style for the tasks
\define@key[psset]{}{TaskStyle}{\def\psk@GanttTaskStyle{#1}}
% Which line (for multiple tasks in one line)
\newif\ifPst@GanttSameLine
\define@key[psset]{}{SameLine}[true]{\@nameuse{Pst@GanttSameLine#1}}
% Name for unit interval
\define@key[psset]{}{ChartUnitIntervalName}{\def\psk@GanttChartUnitIntervalName{#1}}
% Name for basic unit
\define@key[psset]{}{ChartUnitBasicIntervalName}{\def\psk@GanttChartUnitBasicIntervalName{#1}}
% Unit interval for the tasks (7 for a week, 30 for a month, etc.)
% Warning: define it before "TaskUnitType"!
\define@key[psset]{}{TaskUnitIntervalValue}{%
    \pst@cntg=#1\relax
    \edef\psk@GanttTaskUnitIntervalValue{\the\pst@cntg}}
% Unit type for the tasks (UnitIntervalName or UnitBasicIntervalName)
\define@key[psset]{}{TaskUnitType}{%
    \edef\psk@GanttTaskUnitValue{#1}%
    % Validation of the parameter
    \ifx\psk@GanttTaskUnitValue\psk@GanttChartUnitIntervalName
	\edef\psk@GanttTaskUnitValue{\psk@GanttTaskUnitIntervalValue}%
    \else
	\ifx\psk@GanttTaskUnitValue\psk@GanttChartUnitBasicIntervalName
	    \def\psk@GanttTaskUnitValue{1}%
	\else
	    {\@pstrickserr{GanttTaskUnitType must be `\psk@GanttChartUnitIntervalName'
                   or `\psk@GanttChartUnitBasicIntervalName'
                  (and not `\psk@GanttTaskUnitValue')}\@eha}%
	\fi
    \fi%
}
% Outside label for the tasks
\define@key[psset]{}{TaskOutsideLabel}{\def\psk@GanttTaskOutsideLabel{#1}}
% Inside label for the tasks
\define@key[psset]{}{TaskInsideLabel}{\def\psk@GanttTaskInsideLabel{#1}}
% Maximum outside size label for the tasks (in unit TaskUnitType !)
\define@key[psset]{}{TaskOutsideLabelMaxSize}{%
    \pst@cntg=#1\relax
    \edef\psk@GanttTaskOutsideLabelMaxSize{\the\pst@cntg}}

% Default values
% --------------
% pspicture environment, don't show intervals, default task style,
% unit for tasks is a week (so 7 days), no outside and inside labels
\psset{%
    PstPicture=true,ChartShowIntervals=false,TaskStyle=TaskStyleDefault,
    ChartUnitIntervalName=Week,ChartUnitBasicIntervalName=Day,
    TaskUnitIntervalValue=7,TaskUnitType=Week,SameLine=false,
    TaskOutsideLabel=,TaskInsideLabel=,TaskOutsideLabelMaxSize=0}

\newpsstyle{TaskStyleDefault}{fillstyle=solid,fillcolor=yellow}

% The environment \PstGanttChart
% ------------------------------

% Syntax: \PstGanttChart[parameters]{Number of tasks}{Number of days}
\def\PstGanttChart{\@ifnextchar[\PstGanttChart@i{\PstGanttChart@i[]}}

\def\PstGanttChart@i[#1]#2#3{%
\pst@GanttTaskCnt=\z@  % hv we need it to be reset
\begingroup
\psset{unit=0.1,#1}    % Affectation of local parameters
%
\ifPst@PstPicture               % "pspicture" environment
  \pst@cnta=\psk@GanttTaskOutsideLabelMaxSize
  \multiply\pst@cnta\psk@GanttTaskUnitValue
  %
  \pst@cntb=#2
  \multiply\pst@cntb by 5
  \advance\pst@cntb\@ne
  %
  \pst@cntc=#3
  \multiply\pst@cntc\psk@GanttTaskUnitValue
  \advance\pst@cntc\tw@
  %
  \ifPst@GanttChartShowIntervals
    \pspicture(-\pst@cnta,-\pst@cntb)(\pst@cntc,2)
  \else
    \pspicture(-\pst@cnta,-\pst@cntb)(\pst@cntc,0)
  \fi
\fi
\psframe(0,-\pst@cntb)(\pst@cntc,0)
%
\ifPst@GanttChartShowIntervals
  % We will show the intervals
  \pst@cnta=#3
  \multiply\pst@cnta\psk@GanttTaskUnitValue
  \divide\pst@cnta\psk@GanttTaskUnitIntervalValue
  \advance\pst@cnta\@ne
  %
  \pst@cntb=#2
  \multiply\pst@cntb by 5
  \advance\pst@cntb\@ne
  %
  \pst@dima=\psk@GanttTaskUnitIntervalValue pt
  \divide\pst@dima\tw@
  \advance\pst@dima\@ne pt
  \pst@dimtonum{\pst@dima}{\pst@tempa}
  %
  \multido{\iInterval=1+1,\iIntervalPos=1+\psk@GanttTaskUnitIntervalValue,
           \nIntervalPos=\pst@tempa+\psk@GanttTaskUnitIntervalValue.0}{\pst@cnta}{%
    \ifnum\iInterval=\pst@cnta
      \psline(\iIntervalPos,0)(\iIntervalPos,1.5)
      \psline[linestyle=dotted](\iIntervalPos,-\pst@cntb)(\iIntervalPos,0)
    \else
      \rput(\nIntervalPos,1){\psk@GanttChartUnitIntervalName\space\iInterval}
      \psline(\iIntervalPos,0)(\iIntervalPos,1.5)
      \psline[linestyle=dotted](\iIntervalPos,-\pst@cntb)(\iIntervalPos,0)
    \fi}
\fi}

\def\endPstGanttChart{%
\ifPst@PstPicture
  \endpspicture                 % End of "pspicture" environment
\fi
\endgroup%
}

% The macro \PstGanttTask
% -----------------------

\newcount\pst@GanttTaskCnt
\pst@GanttTaskCnt=\z@

% Syntax: \PstGanttTask[parameters]{Start}{Length}
\def\PstGanttTask{\@ifnextchar[\PstGanttTask@i{\PstGanttTask@i[]}}

\def\PstGanttTask@i[#1]#2#3{%
\advance\pst@GanttTaskCnt\m@ne
\begingroup
\psset{#1}%            % Affectation of local parameters
\ifPst@GanttSameLine
  \global\advance\pst@GanttTaskCnt\@ne
\fi
% Frame
\pst@cnta=\psk@GanttTaskUnitValue
\multiply\pst@cnta by #2
\advance\pst@cnta\@ne
%
\pst@cntb=\psk@GanttTaskUnitValue
\multiply\pst@cntb by #3
\advance\pst@cntb\pst@cnta
%
\pst@cntc=\pst@GanttTaskCnt
\multiply\pst@cntc by 5
%
\pst@cntd=\pst@cntc
\advance\pst@cntd by 4
%
\psframe[style=\psk@GanttTaskStyle](\pst@cnta,\pst@cntc)(\pst@cntb,\pst@cntd)
% Inside label
\ifx\psk@GanttTaskInsideLabel\empty
\else
  \pst@dima=\pst@cnta pt
  \advance\pst@dima\pst@cntb pt
  \divide\pst@dima\tw@
  \pst@dimtonum{\pst@dima}{\pst@tempa}
  %
  \pst@dimb=\pst@cntc pt
  \advance\pst@dimb\pst@cntd pt
  \divide\pst@dimb\tw@
  \pst@dimtonum{\pst@dimb}{\pst@tempb}
  %
  \rput(\pst@tempa,\pst@tempb){\psk@GanttTaskInsideLabel}
\fi
% Outside label
\ifx\psk@GanttTaskOutsideLabel\empty
\else
  \pst@dimb=\pst@cntc pt
  \advance\pst@dimb\pst@cntd pt
  \divide\pst@dimb\tw@
  \pst@dimtonum{\pst@dimb}{\pst@tempb}
  \rput[r](-1.5,\pst@tempb){\psk@GanttTaskOutsideLabel}
\fi
\endgroup% Affectation of local parameters
}

\makeatother


\begin{document}

\newpsstyle{Important}{fillstyle=solid,fillcolor=red}
\newpsstyle{NotImportant}{fillstyle=vlines}
\begin{PstGanttChart}{5}{7}
  \PstGanttTask{0}{3}
  \PstGanttTask[TaskStyle=NotImportant,SameLine=true]{4}{2}
  \PstGanttTask{2}{1}
  \PstGanttTask[TaskStyle=Important,TaskInsideLabel=Important]{2}{5}
  \PstGanttTask[TaskStyle=NotImportant]{4}{2}
  \PstGanttTask{5}{2}
\end{PstGanttChart}

\vspace{1cm}
\begin{PstGanttChart}[yunit=2]{5}{7}
  \PstGanttTask{0}{3}
  \PstGanttTask[SameLine]{4}{2}
  \PstGanttTask{2}{1}
  \PstGanttTask[TaskStyle=Important,TaskInsideLabel=Important]{2}{5}
  \PstGanttTask[TaskStyle=NotImportant]{4}{2}
  \PstGanttTask{5}{2}
\end{PstGanttChart}

\vspace{1cm}
\begin{PstGanttChart}[unit=2,TaskOutsideLabelMaxSize=1,
                      ChartShowIntervals]{5}{7}
  \PstGanttTask[TaskOutsideLabel={Task 1}]{0}{3}
  \PstGanttTask[TaskOutsideLabel={Task 2},TaskUnitType=Day]
               {15}{3} % 3 days starting at day 15
  \PstGanttTask[TaskStyle=Important,TaskOutsideLabel={Task 3},
    TaskInsideLabel={\Large\textcolor{white}{\textbf{Important}}}]{2}{5}
  \PstGanttTask[TaskStyle=NotImportant,TaskOutsideLabel={Task 4}]{4}{2}
  \PstGanttTask[TaskOutsideLabel={Task 5}]{5}{2}
\end{PstGanttChart}

\vspace{1cm}
\begin{PstGanttChart}[yunit=2,ChartUnitIntervalName=Month,
                      TaskUnitIntervalValue=30,TaskUnitType=Month,
                      ChartShowIntervals]{3}{4}
  \PstGanttTask[TaskInsideLabel={Task 1}]{0}{1}
  \PstGanttTask[TaskInsideLabel={Task 1'},SameLine]{3}{1}
  \PstGanttTask[TaskInsideLabel={Task 2},TaskUnitType=Day]
               {24}{40} % 40 days starting at day 24
  \PstGanttTask[TaskInsideLabel={Task 3}]{2}{2}
\end{PstGanttChart}

\vspace{1cm}
\begin{PstGanttChart}[yunit=1.5,ChartUnitIntervalName=Year,
                      ChartUnitBasicIntervalName=Month,
                      TaskUnitIntervalValue=12,TaskUnitType=Year,
                      ChartShowIntervals]{4}{4}
  \PstGanttTask[TaskInsideLabel={Task 1}]{0}{1}
  \PstGanttTask[TaskInsideLabel={Task 2},TaskUnitType=Month]
               {6}{24} % 24 months starting at month 6
  \PstGanttTask[TaskInsideLabel={Task 3}]{2}{2}
  \PstGanttTask[TaskInsideLabel={Task 4}]{3}{1}
\end{PstGanttChart}

\vspace{1cm}
\definecolor{LightCyan}   {rgb}{0.88,1.,1.}
\definecolor{Orange}      {rgb}{1.,0.65,0.}
\definecolor{PaleGreen}   {rgb}{0.6,0.98,0.6}
\definecolor{Pink}        {rgb}{1.,0.75,0.8}

\psset{gradmidpoint=0,fillstyle=gradient,gradbegin=LightCyan,gradend=white}
\newpsstyle{TaskStyleA}{gradbegin=cyan,gradend=blue}
\newpsstyle{TaskStyleB}{gradbegin=red,gradend=Pink}
\newpsstyle{TaskStyleC}{gradbegin=yellow,gradend=Orange}
\newpsstyle{TaskStyleD}{gradbegin=green,gradend=PaleGreen}

\begin{landscape}
\begin{PstGanttChart}[yunit=2.5,xunit=3.5,ChartUnitIntervalName=Semaine,
                      ChartUnitBasicIntervalName=Jour,TaskUnitType=Jour,
                      TaskOutsideLabelMaxSize=14,ChartShowIntervals]{8}{43}
  \psset{gradangle=90,TaskStyle=TaskStyleA}
  \PstGanttTask[TaskOutsideLabel={\'Etude}]{0}{10}
  \PstGanttTask[TaskOutsideLabel={R\'edaction dossier}]{6}{7}
  \PstGanttTask[TaskOutsideLabel={Relecture et corrections}]{14}{2}
  \PstGanttTask[TaskOutsideLabel={Soumission},TaskStyle=TaskStyleB]{17}{1}
  \psset{TaskStyle=TaskStyleC}
  \PstGanttTask[TaskOutsideLabel={R\'ealisation}]{25}{14}
  \PstGanttTask[TaskOutsideLabel={Tests}]{35}{6}
  \PstGanttTask[TaskOutsideLabel={V\'erification}]{39}{3}
  \PstGanttTask[TaskOutsideLabel={Recette},TaskStyle=TaskStyleD]{42}{1}
\end{PstGanttChart}
\end{landscape}

\end{document}
